<template>
	<view class="container b-f">
		<!-- 顶部选项卡 -->
		<view class="swiper-tab dis-flex box-align-center flex-y-center">
			<block v-for="(item, index) in tabList" :key="index">
				<view class="swiper-tab-item" :class="{ on: dataType == item.value }" :data-current="item.value" @tap="swichNav">{{ item.text }}</view>
			</block>
		</view>
		<mescroll-body @init="mescrollInit" @down="downCallback" @up="upCallback" :top="'80rpx'">
			<view class="widget-list" v-if="list.length">
				<view class="widget__detail dis-flex flex-x-between" v-for="(item, index) in list" :key="index">
					<view class="detail__left dis-flex flex-dir-column flex-x-around">
						<view class="detail__money f-30">提现 {{ item.money }}元</view>
						<view class="detail__time col-9 f-24">{{ item.create_time }}</view>
					</view>
					<view class="detail__right dis-flex flex-dir-column flex-x-center flex-y-center">
						<view :class="'detail__status f-28 ' + (item.apply_status == 20 || item.apply_status == 40 ? 'col-green' : 'col-m')">{{ applyStatus[item.apply_status] }}</view>
						<template v-if="item.apply_status == 30">
							<view class="detail__reason f-24" @tap="triggerReasonMsg" :data-reason="item.reject_reason">查看原因</view>
						</template>
					</view>
				</view>
			</view>
		</mescroll-body>
	</view>
</template>

<script>
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins.js';
export default {
	mixins: [MescrollMixin], // 使用mixin
	data() {
		return {
			applyStatus: [],
			dataType: -1,
			list: { data: [] },
			tabList: [
				{
					value: -1,
					text: '全部'
				},
				{
					value: 10,
					text: '审核中'
				},
				{
					value: 20,
					text: '审核通过'
				},
				{
					value: 40,
					text: '已打款'
				},
				{
					value: 30,
					text: '驳回'
				}
			]
		};
	},
	onLoad(options) {
		this.dataType = options.status || -1;
		const applyStatus = {};
		this.tabList.forEach(item => {
			applyStatus[item.value] = item.text;
		});
		this.applyStatus = applyStatus;
	},
	onShow() {
		// 获取提现明细列表
		// this.getWithdrawList();
	},
	methods: {
		/**
		 * 获取提现明细列表
		 */
		upCallback(mescroll) {
			this.$u.api.getWithdrawList(this.dataType, mescroll.num).then(res => {
				const listData = res.data.list;
				console.log(listData.data);
				if (mescroll.num == 1) {
					this.list = listData.data;
				} else {
					this.list.push(listDatat.data);
				}
				this.mescroll.endBySize(listData.data.length, listData.total);
			});
		},
		getWithdrawList(isNextPage, page) {},

		/**
		 * 点击tab切换
		 */
		swichNav(e) {
			let current = e.target.dataset.current;
			if (this.dataType == current) {
				return false;
			}
			this.dataType = current;
			this.mescroll.resetUpScroll(true);
		},
		/**
		 * 查看驳回原因
		 */
		triggerReasonMsg: function(e) {
			uni.showModal({
				title: '驳回理由',
				content: e.currentTarget.dataset.reason,
				showCancel: false
			});
		}
	}
};
</script>

<style>
page {
	background: #fff;
}

/* 选项卡 */

.swiper-tab {
	width: 750rpx;
	text-align: center;
	height: 80rpx;
	background-color: #fff;
	border-bottom: 1px solid #eee;
	position: fixed;
	top: calc(var(--window-top));
	left: 0;
	z-index: 10;
}

.swiper-tab .swiper-tab-item {
	width: 33.333333%;
	height: 100%;
	font-size: 28rpx;
	color: #777;
	display: flex;
	justify-content: center;
	align-items: center;
	box-sizing: border-box;
	border-bottom: 2px solid #ffffff00;
}

.swiper-tab .on {
	color: #786cff;
	border-bottom: 2px solid #786cff;
}

/* 设置scroll-view容器高度 */

.widget-list,
.yoshop-notcont {
	height: 100.1%;
}

/* 提现明细列表 */

.widget-list {
	padding: 10rpx 20rpx 40rpx 20rpx;
	box-sizing: border-box;
}

.widget__detail {
	padding: 20rpx 15rpx;
	box-sizing: border-box;
	font-size: 28rpx;
	border-bottom: 1rpx solid #e7e7e7;
}

.widget__detail .detail__money {
	font-size: 30rpx;
	margin-bottom: 12rpx;
}

.widget__detail .detail__reason {
	margin-top: 15rpx;
	color: #8e84fc;
}
</style>
